package com.gpay.erp.core.dao.page;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
 * 分页模型，也是所有实体类的基类
 * 
 * @author
 * 
 */
public class PagerModel {
	private int total; // 总数
	private List rows = new ArrayList(); // 分页集合列表
	private int pageSize = 10;// 每页显示记录数
	private int offset; // 偏移量
	private int toRow;// 终
	private int fromRow; // 始
	private int pagerSize;// 总页数
	protected String pagerUrl;// 分页标签需要访问的ACTION地址
	private String id = null;
	private int recordsTotal;
	private int recordsFiltered;
	private int draw;
	private String sort;// 排序字段
	private String order;// asc/desc

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public List getRows() {
		return rows == null ? new LinkedList() : rows;
	}

	public void setRows(List rows) {
		this.rows = rows;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public int getToRow() {
		return toRow;
	}

	public void setToRow(int toRow) {
		this.toRow = toRow;
	}

	public int getFromRow() {
		return fromRow;
	}

	public void setFromRow(int fromRow) {
		this.fromRow = fromRow;
	}

	public int getPagerSize() {
		return pagerSize;
	}

	public void setPagerSize(int pagerSize) {
		this.pagerSize = pagerSize;
	}

	public String getPagerUrl() {
		return pagerUrl;
	}

	public void setPagerUrl(String pagerUrl) {
		this.pagerUrl = pagerUrl;
	}

	public int getRecordsTotal() {
		return recordsTotal;
	}

	public void setRecordsTotal(int recordsTotal) {
		this.recordsTotal = recordsTotal;
	}

	public int getRecordsFiltered() {
		return recordsFiltered;
	}

	public void setRecordsFiltered(int recordsFiltered) {
		this.recordsFiltered = recordsFiltered;
	}

	public int getDraw() {
		return draw;
	}

	public void setDraw(int draw) {
		this.draw = draw;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.jeeshop.common.page.ClearBean#clear()
	 */
	public void clear() {
		total = 0; // 总数
		rows = null; // 分页集合列表
		offset = 0; // 偏移量
		pagerSize = 0;// 总页数
		// pagerUrl = null;//分页标签需要访问的ACTION地址
		recordsTotal = 0;
		id = null;
	}

	public String trim(String str) {
		if (str == null) {
			return null;
		}
		return str.trim();
	}

	public void clearList(List<String> list) {
		if (list == null || list.size() == 0) {
			return;
		}
		list.clear();
		list = null;
	}

	public void clearSet(Set<String> set) {
		if (set == null || set.size() == 0) {
			return;
		}
		set.clear();
		set = null;
	}

	public void clearListBean(List<PagerModel> list) {
		if (list == null || list.size() == 0) {
			return;
		}
		for (int i = 0; i < list.size(); i++) {
			ClearBean item = (ClearBean) list.get(i);
			item.clear();
			item = null;
		}
		list.clear();
		list = null;
	}

	public void clearArray(String[] arr) {
		if (arr == null || arr.length == 0) {
			return;
		}
		for (int i = 0; i < arr.length; i++) {
			arr[i] = null;
		}
		arr = null;
	}

	@Override
	public String toString() {
		return "total:" + total + ",rows:" + rows + ",offset:" + offset;
	}
}
